
module.exports = {
  noSellIfMarketInfo () {
    if (this.ifOnlyPingKongByReason) {
      return
    }
    if (!this.marketInfo) {
      return
    }
    if (this.ifCanIgnoreNoSell) {
      return
    }
    if (this.marketInfo && this.marketInfo.attack15m) {
    }
    if (this.marketFlagInfo.indexIfMarketDownTrend) {
      if (this.marketInfo.ema15mGood || this.marketInfo.macd15mGood) {
        if (!this.marketInfo.kdj15mBad && !this.marketFlagInfo.isMarketLittleBadDown) {
          this.setNoSell('noSellIfMarketInfo-2-1')
        }
      }
    }
    if (
      (this.marketInfo.kdj15mBad && !this.marketInfo.macd15mBad && !this.marketInfo.ema15mBad) &&
      (!this.marketInfo.kdj1hBad && !this.marketInfo.macd1hBad && this.marketInfo.ema1hBad) &&
      !(this.marketFlagInfo.isMarketLittleBadDown)
    ) {
      // 真正的牛股在其他时候就会发出买入信号
      this.setNoSell('noSellIfMarketInfo-3-1')
    }
    // if (this.marketFlagInfo.ifMarket15mAllBad) {
    //   // 真正的牛股在其他时候就会发出买入信号
    //   this.setNoSell('noSellIfMarketInfo-3-2')
    // }
    if (this.marketFlagInfo.ifMarket4hMacdEmaAllGood && this.marketFlagInfo.ifMarket1hHasGood && this.marketFlagInfo.ifMarket1dHasGood) {
      if (!(
        this.marketFlagInfo.ifMarket15mAllGood
      )) {
        if (this.strategy === '2') {
          this.setNoSell('noSellIfMarketInfo-3-3')
        }
      }
    }
  },
  noSellIfStatusGood () {
    if (this.ifCanIgnoreNoSell) {
      return
    }
    if (this.marketFlagInfo.isMarketBigGoodUp || this.marketFlagInfo.isMarketLittleGoodUp) {
      this.setNoSell('noSellIfStatusGood-1')
    }
    if (this.marketFlagInfo.isMarketLittleGoodUp) {
      if (this.strategy === '2') {
        this.setNoSell('noSellIfStatusGood-2')
      }
    }
    // macd第一个k容易发疯
    if (this.marketMachine.ifMarket1dModelLike([1, [0, 1], [0, 1]])) {
      if (this.strategy === '2' && this.analysisInfo1d.macdUpDays === 1) {
        this.setNoSell('noSellIfStatusGood-3')
      }
    }
    if (
      this.marketMachine.ifMarket4hModelLike([1, 1, [0, 1]]) &&
      this.marketMachine.ifMarket1dModelLike([[0, 1], [0, 1], [0, 1]])
    ) {
      if (this.strategy === '2' && this.analysisInfo4h.macdUpDays === 1) {
        this.setNoSell('noSellIfStatusGood-4')
      }
    }
  },
  noSellIfNoProfit () {
    if (this.ifOnlyPingKongByReason) {
      return
    }
    if (
      this.symbolAccount.position > 0.3 && this.hasKongPosition &&
      !(this.marketFlagInfo.ifMarket15mAllGood || this.marketFlagInfo.ifMarket15mAllBad) &&
      // 当天涨得多可以再放一笔
      !(this.analysisInfo15m.netChangeRatio > 15 && this.symbolAccount.position < 0.65)
    ) {
      if (this.symbolAccount.incomeRate <= 0.2) {
        this.setNoSell('noSellIfNoProfit-1')
      }
    }
    // 亏损超过本金一个点的东西不允许加仓
    if (this.symbolAccount.position > 0.3 && this.hasKongPosition) {
      if (this.symbolAccount.incomeAssetRate <= -1) {
        this.setNoSell('noSellIfNoProfit-2')
      }
    }
  },
  noSellIfNewHigh () {
    // 新高的东西，不开逆向仓，你要是那么厉害，那就去reason卖出去
    if (
      this.indexFlagInfo.isIndexInNewHighTrend ||
      this.indexFlagInfo.isIndexCloseNowNewHigh ||
      this.indexFlagInfo.isIndexCloseNewHigh
    ) {
      if (!this.marketFlagInfo.ifMarket15mAllGood4Days) {
        this.setNoSell('noSellIfNewHigh-1')
      }
    }
  },
  noSellIfNowDownHigh () {
    // 正负数要搞灵清
    if (
      this.analysisInfo15m.macdDownRate < -40 &&
      this.analysisInfo15m.macd < 0 &&
      this.analysisInfo15m.kdjDiff > 0
    ) {
      this.setNoSell('noSellIfNowDownHigh-1')
    }
    if (
      this.analysisInfo15m.macdDownRate < -40 ||
      this.analysisInfo15m.ema5W10B20Rate < -40
    ) {
      this.setNoSell('noSellIfNowDownHigh-2')
    }
  },
  noSellIfLineBad () {
    if (this.strategy === '2') {
      return
    }
    if (this.ifCanIgnoreNoSell) {
      return
    }
    if (this.ifOnlyPingKongByReason) {
      return
    }
    if (this.analysisInfo15m.macdDownDays >= 20 && this.analysisInfo15m.macdDownDays < 96) {
      // const needleLineTime = this.analysisInfoFlag15m.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo15m.macdDownDays)
      // if (needleLineTime > (0.4 * this.analysisInfo15m.macdDownDays)) {
      //   if (this.strategy === '1') {
      //     this.setNoSell('noSellIfLineBad-1', {
      //       canReverse: true
      //     })
      //   }
      // }
      const upDays = this.analysisInfoFlag15m.getNetChangeRatioUpDaysInRange(this.analysisInfo15m.macdDownDays).days
      if (upDays > (0.5 * this.analysisInfo15m.macdDownDays)) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-2', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.macdDownKeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-3', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.macdDownKeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-3-1', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.macdDownKeepInfo.mdrr > 0.5) {
        // 反向也能恶心死你
        this.setNoSell('noSellIfLineBad-3-2', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo15m.ema5W10B20Days >= 20 && this.analysisInfo15m.ema5W10B20Days < 96) {
      // const needleLineTime = this.analysisInfoFlag15m.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo15m.ema5W10B20Days)
      // if (needleLineTime > (0.4 * this.analysisInfo15m.ema5W10B20Days)) {
      //   if (this.strategy === '1') {
      //     this.setNoSell('noSellIfLineBad-4', {
      //       canReverse: true
      //     })
      //   }
      // }
      const upDays = this.analysisInfoFlag15m.getNetChangeRatioUpDaysInRange(this.analysisInfo15m.ema5W10B20Days).days
      if (upDays > (0.5 * this.analysisInfo15m.ema5W10B20Days)) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-5', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.ema5W10B20KeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-6', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.ema5W10B20KeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-7', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo15m.ema5W10B20KeepInfo.mdrr > 0.5) {
        // 反向也能恶心死你
        this.setNoSell('noSellIfLineBad-7-1', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo15m.ema5W10B20Days >= 15) {
      if (this.analysisInfo15m.ema5W10B20KeepInfo.ftdmrr > 0.7) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-8', {
            canReverse: true
          })
        }
      }
    }
    if (this.analysisInfo15m.kdjDownDays === 1) {
      if (this.analysisInfo15m.lastKdjUpDays === 1) {
        this.setNoSell('noSellIfLineBad-11', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo1h.macdDownDays >= 20) {
      // const needleLineTime = this.analysisInfoFlag1h.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo1h.macdDownDays)
      // if (needleLineTime > (0.4 * this.analysisInfo1h.macdDownDays)) {
      //   if (this.strategy === '1') {
      //     this.setNoSell('noSellIfLineBad-12', {
      //       canReverse: true
      //     })
      //   }
      // }
      const upDays = this.analysisInfoFlag1h.getNetChangeRatioUpDaysInRange(this.analysisInfo1h.macdDownDays).days
      if (upDays > (0.5 * this.analysisInfo1h.macdDownDays)) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-12-1', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdDownKeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-12-2', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdDownKeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-12-3', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdDownKeepInfo.mdrr > 0.5) {
        // 反向也能恶心死你
        this.setNoSell('noSellIfLineBad-12-4', {
          canReverse: true
        })
      }
    }
    if (this.analysisInfo1h.ema5W10B20Days >= 20) {
      // const needleLineTime = this.analysisInfoFlag1h.getBeforeRecentDaysNeedleLineTimes(this.analysisInfo1h.ema5W10B20Days)
      // if (needleLineTime > (0.4 * this.analysisInfo1h.ema5W10B20Days)) {
      //   if (this.strategy === '1') {
      //     this.setNoSell('noSellIfLineBad-13', {
      //       canReverse: true
      //     })
      //   }
      // }
      const upDays = this.analysisInfoFlag1h.getNetChangeRatioUpDaysInRange(this.analysisInfo1h.ema5W10B20Days).days
      if (upDays > (0.5 * this.analysisInfo1h.ema5W10B20Days)) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-13-1', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.ema5W10B20KeepInfo.rrncs < 0.3) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-13-2', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.ema5W10B20KeepInfo.ftdmrr > 0.5) {
        if (this.strategy === '1') {
          this.setNoSell('noSellIfLineBad-13-3', {
            canReverse: true
          })
        }
      }
      if (this.analysisInfo1h.macdDownKeepInfo.mdrr > 0.5) {
        // 反向也能恶心死你
        this.setNoSell('noSellIfLineBad-13-4', {
          canReverse: true
        })
      }
    }
    if (this.strategy === '2' && Math.abs(this.analysisInfo15m.emaMaxDiff) < 1) {
      this.setNoSell('noSellIfLineBad-14', {
        canReverse: true
      })
    }
    if (this.analysisInfoFlag1h.countLowNetChangeTimes(60) >= 30) {
      if (['BTC', 'ETH'].indexOf(this.btbItem.code) === -1) {
        this.setNoSell('noSellIfLineBad-15', {
          canReverse: true
        })
      }
    }
    if (this.strategy === '1' && !(this.marketInfo.kdj1hBad || this.marketInfo.kdj15mBad)) {
      if (this.analysisInfo15m.netChangeRatio < 0 && this.analysisInfo15m.macd < 0) {
        // this.setNoSell('noSellIfLineBad-16')
      }
    }
    if (this.symbolAccount.position > 0.3 && this.hasKongPosition && this.btbItem.strategy === '2') {
      if (this.indexFlagInfo.isIndexCloseNewHigh && !this.is4hChangeTime) {
        this.setNoSell('noSellIfLineBad-17')
      }
    }
  },
  neverSellIfLineBad () {
    if (this.analysisInfoFlag1h.countLowNetChangeTimes(60) >= 30) {
      if (['BTC', 'ETH'].indexOf(this.btbItem.code) === -1) {
        this.setNoSell('neverSellIfLineBad-1')
      }
    }
    if (this.analysisInfoFlag4h.countLowNetChangeTimes(60) >= 30) {
      if (['BTC', 'ETH'].indexOf(this.btbItem.code) === -1) {
        this.setNoSell('neverSellIfLineBad-2')
      }
    }
    if (
      !this.analysisInfo1d.hasFullData &&
      this.btbItem.price_change_percent > 150
    ) {
      this.setNoSell('neverSellIfLineBad-4')
    }
    // 整体跌幅大，或者是-35：2025/10/11 5:30，可能-10也行
    if (this.marketInfo.k15mNetChangeRatio < -15) {
      this.setNoSell('neverSellIfLineBad-5')
    }
  }
}
